<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        var num = 18;
        var flag = true;
        var t;
        var aa = null;
        // console.log(num.toString());
        // console.log(flag.toString());
        // console.log(t.toString()); TypeError  undefined 不能使用toString
        // console.log(aa.toString()); TypeError  null 不能使用toString

        //这种可以转换
        // console.log(String(num));
        // console.log(String(flag));
        // console.log(String(t));
        // console.log(String(aa));
        
        //推荐使用这种更加简洁方便
        console.log( num + '');
        console.log( flag + '');
        console.log( t + '');
        console.log( aa + '');
    </script>
</body>

</html>